package com.gqz.controller.system;

import com.gqz.domain.SysOperLog;
import com.gqz.query.BaseQuery;
import com.gqz.service.ISysOperLogService;
import com.gqz.utils.JsonResult;
import com.gqz.utils.PageList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/sys/log")
public class SysOperLogController {

    @Autowired
    private ISysOperLogService sysOperLogService;

    /**
     * 查询 允许空值上传
     *
     * @param query
     * @return
     */
    @GetMapping({"/{pageIndex}/{pageSize}/{keyword}", "/{pageIndex}/{pageSize}", ""})
    public JsonResult list(BaseQuery query) {
        PageList<SysOperLog> list = sysOperLogService.getAllOperLog(query);
        return JsonResult.ok(list);
    }

//    @PutMapping
//    public JsonResult edit(@RequestBody SysOperLog log) {
//        boolean result = sysOperLogService.updateOperLog(log);
//        return result ? JsonResult.ok() : JsonResult.fail();
//    }
//
//    @PostMapping
//    public JsonResult add(@RequestBody SysOperLog log) {
//        boolean result = sysOperLogService.insertOperLog(log);
//        return result ? JsonResult.ok() : JsonResult.fail();
//    }

    @DeleteMapping
    public JsonResult remove(@RequestBody Long[] ids) {
        boolean result = sysOperLogService.batchDeleteOperLog(ids);
        return JsonResult.toAjax(result);
    }

    @DeleteMapping("/{id}")
    public JsonResult remove(@PathVariable Long id) {
        boolean result = sysOperLogService.deleteOperLog(id);
        return JsonResult.toAjax(result);
    }

}
